var BSTMG = BSTMG || {};
BSTMG.userManager = {
	init: function(){
		var that = this;
		//分页功能
		that.showUserList();
	},
	showUserList: function(){
		BSTMG.common.hjhPages('/userAdmin/userList/search',function(data){
			var userList = data.userList;
            var $tbody = $("#userList tbody"),
                html = '';
            if (userList.length > 0) {
                for (var i = 0; i < userList.length; i++) {
                    var userInfo = userList[i];
                    var accountMoney = setAccountMoney(userInfo);
                    var loginNum = setLoginNum(userInfo);
                    html += '<tr class="odd">';
                    html += '<td>' + (i + 1) + '</td>';
                    html += '<td>' + BSTMG.tools.checkNull(loginNum) + '</td>';
                    html += '<td>' + BSTMG.tools.checkNull(userInfo.phone) + '</td>';
                    html += '<td>' + parseFloat(accountMoney).toFixed(2) + '元</td>';
                    html += '<td>' + BSTMG.tools.checkNull(userInfo.belongCompanyName) + '</td>';
                    html += '<td>' + BSTMG.tools.checkNull(userInfo.companyDomainName) + '</td>';
                    html += '<td>' + BSTMG.tools.checkNull(userInfo.provinceCodeName) + BSTMG.tools.checkNull(userInfo.cityCodeName) + BSTMG.tools.checkNull(userInfo.areaCodeName) + BSTMG.tools.checkNull(userInfo.address) + '</td>';
                    html += '<td><a class="btn btn-primary" href="/userAdmin/userDetail/' + userInfo.userId + '">查看详情</a></td>';
                    html += '</tr>';
                }
                $tbody.html(html);
            } else {
                var $tr = '<tr class="odd"><td colspan="7">暂无数据！</td></tr>';
                $tbody.html($tr);
                alert("查询失败！")
            }
		});
	}
}

$(function(){
	BSTMG.userManager.init();
});

//设置登陆账号
function setLoginNum(userInfo){
	if(userInfo.userEmail != "" && userInfo.userEmail != null){
		return userInfo.userEmail;
	}else if(userInfo.userTel != "" && userInfo.userTel != null){
		return userInfo.userTel;
	}else{
		return "";
	}
}

function setAccountMoney(userInfo){
	if(userInfo.accountMoney != "" && userInfo.accountMoney != null){
		return userInfo.accountMoney;
	}else{
		return 0.00;
	}
}





